Show language: C# VB.NET Both
Below are some example use scenarios of the controls, please refer to the API documentation for additional detail.
This example shows how to use the multi-lingual spelling control on the page holding the SearchResult control. In the code below, the Text property controls the MessageLabel text, the CustomDictionaryPath is an optional way to specify the text file to be used as a custom word list (see below), the SuggestedLink is a Hyperlink control (with all the same available properties as a Hyperlink control) and the MessageLabel is a Label control (again, all properties of Label are available).
By default a US & UK English dictionary is used for spelling suggestions, however alternative dictionaries can be used by setting the Language property in the SearchSuggestions control. The Language property may be set to values in the Keyoti.SearchEngine.Suggestions.LanguageType enum (eg. Danish, Dutch, English, EnglishAustralia, EnglishCanada, EnglishMedical , EnglishUK, EnglishUS, French, German, Italian, Norwegian, Polish, Portuguese, Spanish, SpanishLatinAmerica, Swedish, Russian).
Download and unzip the .dict file(s) required and place it in a folder under the Index Directory called "Dictionaries" (creating if need be). For example - myApp\IndexDirectory\Dictionaries\DICT-DE-DE-German_SE.dict. The dictionary files must not be renamed, as their language is determined from the filename.
Please download the language pack here.<SearchEngine:SearchSuggestions id=SearchSuggestions1 runat="server" Language="German" > <SuggestedLink Font-Italic="True">suggestedExpression</SuggestedLink> <MessageLabel Font-Bold="True"></MessageLabel> </SearchEngine:SearchSuggestions>
keyoti
keyoti's
rapidspell
<SearchEngine:SearchSuggestions id=SearchSuggestions1 runat="server" CustomDictionaryPath='<%# MapPath("custom_dictionary.txt") %>' Text="Did you mean? "> <SuggestedLink Font-Italic="True">suggestedExpression</SuggestedLink> <MessageLabel Font-Bold="True"></MessageLabel> </SearchEngine:SearchSuggestions>
To customize the spelling suggestions provided by the SearchSuggestions control, we handle the OnFoundSpellingError event:
<SearchEnginePro:SearchSuggestions ID="SS" runat="server" SpellingSuggestionSource="PresetDictionary" OnFoundSpellingError="SS_FoundSpellingError" />
and in the code behind we work with the event arguments to customize the suggestions as we choose;
protected void SS_FoundSpellingError(object sender, Keyoti.SearchEngine.Web.FoundSpellingErrorEventArgs e)
{
//Obtain the misspelled word if we need it.
string badWord = e.Word;
//Obtain the suggestions provided by the control
ArrayList spellingSuggestions = e.Suggestions;
//Use whatever logic we choose to change the top suggestion. In this case it's always "CUSTOM"
spellingSuggestions.Insert(0, "CUSTOM");
}
Protected Sub SS_FoundSpellingError(ByVal sender As Object, ByVal e As Keyoti.SearchEngine.Web.FoundSpellingErrorEventArgs)
'Obtain the misspelled word if we need it.
Dim badWord As String = e.Word
'Obtain the suggestions provided by the control
Dim spellingSuggestions As ArrayList = e.Suggestions
'Use whatever logic we choose to change the top suggestion. In this case it's always "CUSTOM"
spellingSuggestions.Insert(0, "CUSTOM")
End Sub
To obtain a spelling corrected search expression programmatically, use the following code, and ensure that the following DLLs are referenced (in addition to the usual)
Keyoti2.SearchEngine.Suggestions.dll
Keyoti2.SearchEngine.SuggestionsDictionary.dll
Keyoti2.SearchEnginePro.Web.dll
string originalQueryString = "testt query"; //put the query here Keyoti.SearchEngine.Configuration conf = new Keyoti.SearchEngine.Configuration(); Keyoti.SearchEngine.Search.GroupElement testGroup = new Keyoti.SearchEngine.Search.GroupElement(originalQueryString, conf); Keyoti.SearchEngine.Suggestions.SearchSuggestionsModel model = new Keyoti.SearchEngine.Suggestions.SearchSuggestionsModel(); //to use a different .dict file (e.g. for non English languages) pass the path in the first argument instead of 'null'. string suggestedQuery = model.BuildSuggestedExpression(null, null, Keyoti.SearchEngine.Suggestions.LanguageType.English, Keyoti.SearchEngine.Suggestions.SpellingSuggestionSource.PresetDictionary, conf, 0, testGroup, originalQueryString);